;(function (global){ 
	var CGI = {
			PROMOTION_LINK_DEl: window.frontPath + 'promotionLink/delProLink',//删除
			PROMOTION_LINK_QUERY: window.frontPath + 'promotionLink/queryProLink'//查询历史记录
	};
	//初始化输入框默认提示组件
	$.placeholder.init();
	/**
	 * 按条件查询
	 */
    window.P(
			1,
			'#promotion-search-form' , 
			 CGI.PROMOTION_LINK_QUERY , 
			'#promotion-z-template' , 
			'#promotion-data' , 
			15
		); 
	
    $('#promotion-table').delegate('[data-flag="scanPromLink"]' , 'click' , function (){
    	  var _link = $(this).parents('tr').attr('data-link');
		  window.open(window.frontPath+"promLink/"+_link,"推广链接");
	});
    
    
	$('#promotion-table').delegate('[data-flag="data-promotion"]' , 'click' , function (){
		  location.href=window.frontPath+"home#/promotionLink/toReg";
	});
	
	$('#promotion-data').delegate('[data-flag="updatePromLink"]' , 'click' , function (){
		  var _uid = $(this).parents('tr').attr('data-uid');
		  location.href=window.frontPath+"home#/promotionLink/toUpdateProm/"+_uid;
	});
	
	$('#promotion-data').find('[data-flag="copyPromLink"]').each(function (obj,index){
		  var _link = $(obj).parents('tr').attr('data-link');
	});
	
	$('#promotion-data').delegate('[data-flag="delPromLink"]' , 'click' , function (){
		  var _uid = $(this).parents('tr').attr('data-uid');
		 	$.alert({
	    		status : 'help',
				basicTitle : '您确定要删除该条推广链接？',
				buttons : [{'flag' : 'ok' , 'name' : '确定' , 'handler' : function(){
					$.ajax({ 
					    url: CGI.PROMOTION_LINK_DEl, 
					    data: "id="+_uid, 
					    success: function(data) {
					    	if(data.retcode ===0){
					    		$.none_alert(function()
					    		{ 
					    			window.P(
					    					1,
					    					'#promotion-search-form' , 
					    					 CGI.PROMOTION_LINK_QUERY , 
					    					'#promotion-z-template' , 
					    					'#promotion-data' , 
					    					15
					    				);
					    		}		
					    		);
					    	}else{
					    		$.exception(data.retcode , data.retmsg);
					    	}
					    }
					});
				}},{'flag' : 'cancel' , 'name' : '取消' , 'handler' : function (){
					$.none_alert();
				}}]
			});
	}); 
})(window);